home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / flex / flexb237.zoo / yyread.c < prev   
C/C++ Source or Header  |  1991-08-03  |  726b  |  34 lines

  1. #ifdef atarist
  2.  
  3. #include <unistd.h>
  4.  
  5. /*
  6.  * read, ignoring CR's
  7.  *
  8.  *  ++jrb
  9.  *  revised by mjf
  10.  */
  11. int _yyread(int fd, char *buf, int size)
  12. {
  13.     register char c;
  14.     register char *in;
  15.     register char *intop;
  16.     register char *out = buf;
  17.              int count;
  18.  
  19.     do {
  20.         in = out;
  21.         count = read(fd, in, size);     /* get some more characters */
  22.         if (count <= 0) return count;   /* did we get anything? */
  23.         intop = in + count;             /* remove '\r' characters */
  24.         while (in != intop) {
  25.             c = *in++;
  26.             if(c != '\r') *out++ = c;
  27.         }
  28.     } while(out == buf);                /* try again if nothing remains */
  29.  
  30.     return (out - buf);
  31. }
  32.  
  33. #endif /* atarist */
  34.